﻿using System;
using Castle.ActiveRecord;
using NHibernate;
using NHibernate.Collection.Generic;
using System.Collections.Generic;

namespace ContactManager.Models.Entities
{
    [ActiveRecord]
    public class ContactGroup : ActiveRecordBase<ContactGroup>
    {
        
        private System.Guid _Id;
        private string _name;
        private IList<Contact> contacts = new List<Contact>();


        public ContactGroup()
    {
      
    }

        public ContactGroup(string name)
            : this()
        {
            this._name = name;
        }

        [PrimaryKey(PrimaryKeyType.Assigned)]
        public System.Guid Id
        {
            get { return _Id; }
            set { _Id = value; }
        }

        [Property]
        public string Name
        {
            get { return _name; }
            set { _name = value; }
        }

                
        [HasMany(typeof(Contact), Table="Contacts", 
            ColumnKey="GroupId", 
            Inverse=true,
            Cascade = ManyRelationCascadeEnum.AllDeleteOrphan)]
        public IList<Contact> Contacts
        {
            get { return contacts; }
            set { contacts = value; }
        }

        

    }
}